package kr.hkit.powerjava.algorithm;

import java.util.*;

class BinarySearch{
	private int right=9;
	private int left=0;
	int[] arrBinary = {1,2,3,4,5,6,7,8,9,10};
	int searchKey=9;
	private int mid=0;
	
	
/*	public BinarySearch(int size) {
		this.size = size;
		arrBinary;
	}*/
	
	public void search(){
		int mid = (left+right-1)/2;
		if(searchKey > arrBinary[mid]){
			left = mid+1;
			this.right = right;
		}else{
			this.left = left;
			right = mid;
		}
		findNum();
	}
	public void findNum(){
		if(arrBinary[mid] == searchKey){
			System.out.println(arrBinary[mid]);

		}else{

		}
		System.out.println(arrBinary[mid]);
	}
	@Override
	public String toString() {
		return "BinarySearch [arrBinary=" + Arrays.toString(arrBinary)
				+ ", searchKey=" + searchKey + ", mid=" + mid + "]";
	}


	
	
}

public class BinarySearchTest{
	public static void main(String[] args) {
		BinarySearch b1 = new BinarySearch();
		b1.search();
		System.out.println(b1);
		
	}

	
}
